package com.gz.logistics.library.pojo;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 杜志娟 on 2016/4/22.
 */
public class GetClothes implements Serializable {
    private String orderno; //订单编号
    private String client;//用户名字
    private String address;//用户地址
    private String phone;//联系方式
    private double money;//价格
    private String clothgategory;//衣服种类
    private int clothnum;//衣服数量
    private String greservetime;
    private double realmoney;

    public double getRealmoney() {
        return realmoney;
    }

    public void setRealmoney(double realmoney) {
        this.realmoney = realmoney;
    }

    private List<ClothesDetails> detailses;

    public String getOrderno() {
        return orderno;
    }

    public void setOrderno(String orderno) {
        this.orderno = orderno;
    }

    public String getClient() {
        return client;
    }

    public void setClient(String client) {
        this.client = client;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    public String getAddress() {

        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getClothgategory() {
        return clothgategory;
    }

    public void setClothgategory(String clothgategory) {
        this.clothgategory = clothgategory;
    }

    public int getClothnum() {
        return clothnum;
    }

    public void setClothnum(int clothnum) {
        this.clothnum = clothnum;
    }

    public String getGreservetime() {
        return greservetime;
    }

    public void setGreservetime(String greservetime) {
        this.greservetime = greservetime;
    }



    public List<ClothesDetails> getDetailses() {
        return detailses;
    }

    public void setDetailses(List<ClothesDetails> detailses) {
        this.detailses = detailses;
    }

    public static List<GetClothes> parse(JSONArray jsonArray) throws JSONException {
        if (jsonArray == null || jsonArray.length() <= 0){
            return null;
        }
        List<GetClothes> getClothesList = new ArrayList<GetClothes>();
        for (int i = 0 ; i < jsonArray.length() ; i++ ){
            GetClothes getclothes = new GetClothes();
            JSONObject object = jsonArray.getJSONObject(i);
            getclothes.orderno = object.getString("order_no");
            getclothes.client = object.getString("client");
            getclothes.address = object.getString("address");
            getclothes.phone = object.getString("phone");
            getclothes.clothgategory = object.getString("cloth_gategory");
            getclothes.clothnum = object.getInt("cloth_num");
            getclothes.greservetime = object.getString("g_reserve_time");
            getclothes.money = object.getDouble("money");
            getclothes.realmoney = object.getDouble("real_money");
            getclothes.detailses = ClothesDetails.parse(object.getJSONArray("details"));
            getClothesList.add(getclothes);
        }
        return getClothesList;
    }

    public static GetClothes parse(JSONObject object) throws JSONException {
        if (object == null){
            return null;
        }
        GetClothes getclothes = new GetClothes();
        getclothes.orderno = object.getString("order_no");
        getclothes.client = object.getString("client");
        getclothes.address = object.getString("address");
        getclothes.phone = object.getString("phone");
        getclothes.clothgategory = object.getString("cloth_gategory");
        getclothes.clothnum = object.getInt("cloth_num");
        getclothes.greservetime = object.getString("g_reserve_time");
        getclothes.money = object.getDouble("money");
        getclothes.realmoney = object.getDouble("real_money");
        getclothes.detailses = ClothesDetails.parse(object.getJSONArray("details"));
        return getclothes;

    }
}
